using System;
using System.Globalization;
using System.Windows.Data;

namespace WindowsPhoneEssentials.Converters
{
    /// <summary>
    /// Converts true to constant opacity, false to 1
    /// </summary>
    public class BooleanToOpacityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!(value is bool))
            {
                throw new NotSupportedException("BooleanToOpacityConverter should only be used on bool values.");
            }
            if ((bool)value)
            {
                return 0.2;
            }
            return 1;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }
}